﻿using System;

using KingsSharp.Core.Data.Entity;
using CRM.Admin.Contracts.Model.Sys;

namespace Property.Main.Services.EntityConfigurations.Sys
{
    public class OrganizationConfiguration : EntityConfigurationBase<Organization, Guid>
    {
        public OrganizationConfiguration()
        {
            this.Property(a => a.Name).HasMaxLength(80);
            this.Property(a => a.Code).HasMaxLength(10);
            this.Property(a => a.Remark).HasMaxLength(500);

            this.Property(a => a.ParentOrganizationId).IsOptional();
            this.HasOptional(a => a.Parent).WithMany(b => b.Children).HasForeignKey(c => c.ParentOrganizationId);
        }
    }
}
